<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // BOM 
    // history   => length  back forward  go
    // screen    => availWidth  availHeight  width height
    // navigator => userAgent
    // location  => 

    // url
    // https:www.baidu.com/html/index.html?a=1&b=2#one

    // this指向
    // 如果函数调用时没有依存的对象  this->默认指向window
    // 如果函数调用时有依存的对象,调用时属于谁就指向谁

    function fn() {
        console.log(this);
    }

    var a = 10;
    var b = 20;
    var obj = {
        a: 1,
        b: 2,
        sum: function () {
            console.log("函数被调用", this);
            return this.a + this.b;
        }
    }

    // fn();
    // var result = obj.sum();
    // console.log(result);

    var sum = obj.sum;
    // var sum = function () {
    //     console.log("函数被调用", this);
    //     return this.a + this.b;
    // }

    var result = sum();  // this -> window  this.a -> window.a
    console.log(result);



</script>

</html>